<?php

namespace App\Http\Controllers\admin;

use App\Events\PostUpdate;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Post;

class PostController extends Controller
{
    public function index()
    {
        //返回collection集合
        $comments = Post::find(1)->comments()->where('id',1)->first();
        dd($comments);
    }

    public function update()
    {
       // return 'haha';
        $post = Post::find(1);
       // var_dump($post);exit;
        $post->title = 'repaired title';
        $post->update();
        //触发事件
        Event(new PostUpdate($post));
    }
}
